<template>
	<view>
		<view class="bg_orderDetail" style="height: 250rpx;">
			<view class="padding text-white ">待付款</view>
		</view>
		<view class="bg-white padding margin radius align-center " style="margin-top: -100rpx;" @click="addressMen()">
			<view class="align-center">
				<view>
					<image src="/static/dingwei.png" mode="" style="width: 30rpx;height: 30rpx;"></image>
				</view>
				<view class="margin-left-sm">
					<view>{{AddressList.name}}</view>
					<view class="onelineshow">
						地址{{AddressList.sca_name}}{{AddressList.address}}
					</view>
				</view>
				<view class="margin-left" v-if="AddressList==''">
					请选择收货地址
				</view>
			</view>
		</view>
		<view class="bg-white margin padding radius">
			<view class="solid-bottom padding-bottom">
				商品详情
			</view>
			<view>
				<view class="margin-top flex">
					<image :src=" image+signDetailData.img" mode="aspectFill" style="width: 250rpx;height: 200rpx;" class="radius bg-gray"></image>
					<view style="width: 370rpx;">
						<view class=" rowsb margin-left-sm onelineshow">
							<view class="">{{signDetailData.title}}</view>
							<view>{{signDetailData.integral}}积分</view>
						</view>
						<view class="justify-end margin-top">
							X1
						</view>
					</view>
				</view>

			</view>
		</view>

		<view style="height: 140rpx;"></view>
		<view class="bg-white padding-sm position-bottom justify-end solid-top" style="position: fixed;z-index: 1;bottom: 0;left: 0;right: 0;"
		 @click="payTypeDataMen">
			<view class="border padding-lr padding-tb-sm margin-left round" style="color: #235099;border: 1rpx solid #235099;">立即支付</view>
		</view>

	</view>
</template>

<script>
	const app = getApp().globalData
	import {
		getAllAddress,
		integralGoodsOrdering
	} from '../../../common/path.js'
	export default {
		data() {
			return {
				AddressList: [],
				signDetailData: [],
				detailId: '', //商品id
				image: '', //拼接字符串
			}
		},
		onLoad() {
			this.image = app.image
			this.signDetailData = app.integralData
		},
		onShow() {
			this.getAllAddress() //获取订单地址
		},
		methods: {
			//获取地址接口
			getAllAddress() {
				let data = {
					id: app.userInfo.id,
					is_default: 0
				}
				this.$axios.axios('POST', getAllAddress, data)
					.then(res => {
						console.log(res.data)
						if (res.status == 1) {
							this.AddressList = res.data[0]
						}
					})
					.catch(err => {
						console.log(err)
					})
			},
			addressMen() {
				uni.navigateTo({
					url: '/pages/address/address'
				})
			},
			payTypeDataMen() {
				if (this.AddressList.id == '') {
					this.$tools.showToast('请先选择地址')
					return false
				}
				let data = {
					id: this.signDetailData.id,
					num: 1,
					address_id: this.AddressList.id,
					user_id: app.userInfo.id
				}
				this.$axios.axios('POST', integralGoodsOrdering, data)
					.then(res => {
						if (res.status == 1) {
							this.$tools.showToast2('下单成功！')
							setTimeout(r => {
								this.$tools.reLaunch('/pages/my/integralCenter/integralCenter')
							}, 1000)
						} else {
							this.$tools.showToast(res.msg)
						}
						console.log(res);
					})
					.catch(err => {
						console.log(err);
					})
			},
		}
	}
</script>

<style>
	.bg_orderDetail {
		background-color: #235099;
	}
</style>
